package uml.controller;

import uml.GUI.MainWindow;
import uml.eventsystem.IObserver;
import uml.eventsystem.KeyHandler;
import uml.eventsystem.MouseHandler;
import uml.eventsystem.events.UMLEvent;

/**
 * 
 * @author Ricardo Myers
 * @author James Feather
 *
 */
public class Controller implements IObserver
{
	MainWindow m_window;
	
	/**
	 * Default contructor - this will setup the main window with a 
	 * default title bar and GUI.
	 */
	public Controller()
	{
		 m_window = new MainWindow(this);
		 MouseHandler mouseHandler = MouseHandler.getMouseHandler();
		 mouseHandler.registerForAllUMLEvents(this);
		 m_window.addMouseListener(mouseHandler);
	}
	/**
	 * Handles exit notification.
	 */
	@Override
	public void handleNotification (UMLEvent event)
	{
		//UMLObject formatter;
		switch(event.getEventId()){
		case APPLICATION_EXIT:
			m_window.dispose();
			System.exit(0);
			break;
		default:
			break;
		}
	}
}